#!/usr/bin/env node

const http = require('http'),
      log = console.log,
      fs = require('fs');

http.createServer((req,res)=>{
  
  req.on('data',(data)=>{
    let cmd = data.slice(0,data.length-2);

    switch(cmd) {
      case 'ls': {
        let files = fs.readdirSync(_dirname);
        files.forEach(function(f){
          socket.write(f+'\r\n');
        });
        break;

      }
      case 'quit': {
        res.end('ok');
        break;
      }

      default: {
        break;
      }
    }
  })
  
}).listen(8080);
